<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> Webboard </TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-874">
<link href="./style.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY vLink=blue aLink=#d5ae83 link=blue bgcolor=#FFFFE0>
<center><font color=#9400d3><h2>Webboard</h2></font></center>
<?
if(($mode=="")&&$Category){
	include"config.inc.php";
?>
<table width="98%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr> 
<td width="44%">[ <a href="<?echo $url; ?>">Home</a> | <a href="webboard.php?Category=<?echo $Category;?>">กลับหน้าหลักเวปบอร์ด</a> | <a href="webboard.php?mode=postq&Category=<?echo $Category;?>">ตั้งกระทู้ใหม่</a> ]</td>
<td width="56%" align="right">[ <a href="login.php?Category=<?echo $Category;?>">ลบคำถาม - คำตอบ</a> ]</td>
</tr>
	<?
	@mysql_connect($host,$user,$pwd);
	$sql="select * from board_data where Category='$Category' order by No DESC";
	$result=mysql_db_query("$dbname",$sql);
	$NRow=mysql_num_rows($result);
	if($NRow==0){
		echo "</table>\n";
		echo "<center>ยังไม่มีคำถาม</center>\n";
	}else{
		echo "<tr>";
		echo "<form method=post action=\"search.php?Category=$Category\" name=\"SearchForm\">";
		echo "<td width='44%'><font color=green>จํานวนคำถามทั้งหมด<b><font color=red> $NRow </font></b>คำถาม</font></td>";
		echo "<td width='56%' align=right valign=baseline><img src=\"./pic/search.gif\"> ค้นหาคำถาม "; 
		echo "<input type=text name=search size=20 maxlength=100 class=violet> ";
		echo "<input type=submit value='ค้นหา' name=submit class=BUTTON>";
		echo "</td>";
  		echo "</form></tr>";
		echo "</table>";

		echo "<TABLE align=center cellSpacing=0 cellPadding=0 width=98% border=0 bgcolor=#000000>";
		echo "<TR><TD>";
		echo "<table width='100%' border=0 cellpadding=3 cellspacing=1 align='center'>";
  		echo "<tr bgcolor=#686898>";
		echo "<td align=center width=9%><font color=#FFFFFF><b>คำถามที่</b></font></td>\n";
		echo "<td align=center width=44%><font color=#FFFFFF><b>คำถาม</b></font></td>\n";
		echo "<td align=center width=25%><font color=#FFFFFF><b>ผู้ถาม</b> [วันที่ถาม]</font></td>\n";
		echo "<td align=center width=7%><font color=#FFFFFF><b>อ่าน</b></font></td>\n";
		echo "<td align=center width=15%><font color=#FFFFFF><b>ตอบ</b></font></td>\n";
  		echo "</tr>\n\n";

		while ($row = mysql_fetch_array($result)) {
			$bgc = ($bgc=="#FAF2E6") ? "#FFFFCC" : "#FAF2E6";
			$No = sprintf("%05d",$row["No"]);
			$Subject = $row["Subject"];
			$Name = $row["Name"];
			$Day = trim(substr($row["Day"],0,12)); // แสดงเฉพาะวันที่
			$Reply = $row["Reply"];
			#$ReplyDate = substr($row["ReplyDate"],0,11); // แสดงเฉพาะวันท
			if($Reply!=0){
				$icon = ($Reply>=10) ? "<img src='./pic/hotfd.gif'>" : "<img src='./pic/openfd.gif'>";
			}else{
				$icon = "<img src='./pic/closefd.gif'>";
			}
			echo "<tr bgColor=$bgc><td><center>$icon ",$No,"</center></td>";
			echo "<td><a href='webboard.php?mode=show&Category=$Category&No=",$row['No'],"' target='$No'>",$Subject,"</a></td>";
			echo "<td>",$Name," [$Day]</td>";
			echo "<td><center>",$row['vis'],"</center></td>";
			echo "<td><center>",$Reply,"</center></td></tr>\n";
		}
			echo "</table>\n";
		echo "</TD></TR>\n";
		echo "</TABLE>\n";
echo "<img src=\"pic/closefd.gif\"> - คำถามที่ยังไม่มีคนตอบ	<img src=\"pic/openfd.gif\"> - คำถามที่ตอบแล้ว	<img src=\"pic/hotfd.gif\" alt=\"10 คำตอบขึ้นไป\"> - คำถามสุดฮอต\n";
	}
echo "<center>[ <a href=\"webboard.php?mode=postq&Category=$Category\">ตั้งกระทู้ใหม่</a> ]\n";
?>
<br><br>
<< กรุณาใช้ถ้อยคำสุภาพนะครับ >><br><br>
</center>
<?
}elseif(($mode=="admin")&&$Category){
	include"source/admin.php"; //นำไฟล์มาใส่
}elseif(($mode=="postq")&&$Category){
	include"source/postq.php";
}elseif(($mode=="show")&&$Category){
	include"source/show.php";
}elseif(($mode=="reply")&&$Category){
	include"source/reply.php";
}else{
	echo "<b>มีปัญาอย่างไม่ทราบสาเหตุ</b><br>\n";
	echo "<a href='?Category=general'>กระทู้ทั่วไป</a>";
}
?>
</BODY>
</HTML>